//
//  QSMainTabBarController.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/16.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "QSMainTabBarController.h"
#import "QSHomeViewController.h"
#import "QSEnterpriseVisitViewController.h"
#import "QSWorkStationViewController.h"
#import "QSMineViewController.h"
@interface QSMainTabBarController ()

@end

@implementation QSMainTabBarController

+ (void)initialize
{
    UITabBarItem *appearance = [UITabBarItem appearance];
    
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor QSColorGrayACB3C3];
    attrs[NSFontAttributeName] = [UIFont fontTabBarTitle];
    [appearance setTitleTextAttributes:attrs forState:UIControlStateNormal];
    
    NSMutableDictionary *selectAttrs = [NSMutableDictionary dictionary];
    selectAttrs[NSForegroundColorAttributeName] = [UIColor QSColorBlue3F7DEF];
    selectAttrs[NSFontAttributeName] = [UIFont fontTabBarTitle];
    [appearance setTitleTextAttributes:selectAttrs forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // 初始化子控制器
    [self setupChildViewControllers];
    [self.tabBar setBackgroundImage:[UIImage imageWithFrame:CGRectMake(0, 0, kScreenWidth, 0) color:[UIColor whiteColor]]];
//    [self.tabBar setShadowImage:[UIImage imageNamed:@"icon_tab_shadow"]];
    
}



- (void)setupChildViewControllers {
    QSHomeViewController *home = [[QSHomeViewController alloc] init];
    [self addChileVcWithTitle:@"首页" vc:home imageName:@"ic_home_unselect" selImageName:@"ic_home_select"];
    
    QSEnterpriseVisitViewController *service = [QSEnterpriseVisitViewController new];
    [self addChileVcWithTitle:@"驻企服务" vc:service imageName:@"ic_service_unselect" selImageName:@"ic_service_select"];
    
    QSWorkStationViewController *workStation = [QSWorkStationViewController new];
    [self addChileVcWithTitle:@"工作台" vc:workStation imageName:@"ic_workstation_unselect" selImageName:@"ic_workstation_select"];
    
    QSMineViewController *mine = [QSMineViewController new];
    [self addChileVcWithTitle:@"个人中心" vc:mine imageName:@"ic_mine_unselect" selImageName:@"ic_mine_select"];
    

}

- (void)addChileVcWithTitle:(NSString *)title vc:(UIViewController *)vc imageName:(NSString *)imageName selImageName:(NSString *)selImageName {
    [vc.tabBarItem setTitle:title];
    [vc.tabBarItem setImage:[[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [vc.tabBarItem setSelectedImage:[[UIImage imageNamed:selImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self addChildViewController:[[QSBaseNavigationController alloc] initWithRootViewController:vc]];
}

/**
 *  TabBarController代理
 */
//- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
//
//}



@end
